package com.jiantong.work.impl.dao;

import com.jiantong.work.model.BreedReportSurveyRecord;
import io.terminus.common.mysql.dao.MyBatisDao;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * Created by niufei on 2017/3/15.
 *
 */
@Repository
public class BreedReportSurveyRecordDao extends MyBatisDao<BreedReportSurveyRecord>{

    /**
     * 根据产地检疫的申报单号 查询单条 政府端的数据
     * @param reportId 产地检疫的申报单号
     * @return BreedReportSurveyRecord对象
     */
    public BreedReportSurveyRecord findByReportId(Long reportId){
        return getSqlSession().selectOne(sqlId("findByReportId"),reportId);
    }

    public Long findIdByReportId(Long reportId) throws Exception{
        return getSqlSession().selectOne(sqlId("findIdByReportId"),reportId);
    }

    public List<BreedReportSurveyRecord> findByNameOrNumber(Map criteria){
        return getSqlSession().selectList(sqlId("findByNameOrNumber"),criteria);
    }


    /**
     * 根据检疫证号溯源
     * @param criteria 参数
     * @return BreedReportSurveyRecord
     */
    public BreedReportSurveyRecord findByQuarantineCertNumber(Map<String , Object> criteria){
        return getSqlSession().selectOne(sqlId("findByQuarantineCertNumber"),criteria);
    }
}
